<template>
	<view class=" main">
		<view class="column " style="background-color: #FFFFFF;width: 95%; margin: 10px;border-radius: 5px;">
			<view v-if="planInfo&&planInfo.plan_type==3&&planInfo.is_must==0" style="margin: 10px 0 0 12px;color: #FC4141;font-size: 15px;font-weight: 600;">
				需预约满{{planInfo.lowest_num}}人发车
			</view>
			<view v-if="planInfo&&planInfo.plan_type==3&&planInfo.is_must==1" style="margin: 10px 0 0 12px;color: #ff0a0a;font-size: 15px;font-weight: 600;">
				已众筹拼车成功
			</view>
			<!-- 去程 -->
			<view v-if="planInfo&&planInfo.is_return_trip" class="u-skeleton-fillet">
				<view class="row-center" style="margin: 10px 0 0 12px;color: #000000;font-size: 15px;font-weight: 600;height: 30px;">
				<view class="go-item" >
					去
				</view>
				<text>{{planInfo.date_desc}}</text>
					<text style="margin: 0 8px;">{{planInfo.date_desc_week}} {{planInfo.dp_time}}</text>
					<text v-if="planInfo.plan_type==1||planInfo.plan_type==3">发车</text>
					<text v-else>前乘车</text>
				</view>
				<view class="row-center" style="margin: 10px 12px;font-size: 16px;font-weight: 600;">
					<view style="max-width: 150px" class="line-ellipsis">{{on_stop_name}}</view>
					<text class="iconfont iconchufadaodaxiao" style="margin: 0 5px;"></text>
					<view style="max-width: 150px" class="line-ellipsis">{{off_stop_name}}</view>
				</view>
			</view>
			<!-- 去程 -->
			<!-- 返程 -->
			<view  v-if="planInfo&&planInfo.is_return_trip"  class="u-skeleton-fillet">
				<view class="row-center" style="margin: 10px 0 0 12px;color: #000000;font-size: 15px;font-weight: 600;height: 30px;">
					<view class="back-item">
						返
					</view>
					<text>{{planInfo.return_date}}</text>
						<text style="margin: 0 8px;">{{planInfo.return_date_week}} {{planInfo.return_date_dp}}</text>
						<text>发车</text>
					<!-- 	<view class="row-center" style="margin-left: auto;margin-right: 8px;font-size: 10px;font-weight: 400;color: #ff5303;">
							<text class="iconfont icontongzhan" ></text>
							
							<text>途经站点</text>
						</view> -->
					</view>
					<view class="row-center" style="margin: 10px 12px;font-size: 16px;font-weight: 600;">
						<view style="max-width: 150px" class="line-ellipsis">{{planInfo.destination}}</view>
						<text class="iconfont iconchufadaodaxiao" style="margin: 0 5px;"></text>
						<view style="max-width: 150px" class="line-ellipsis">{{planInfo.origin}}</view>
					</view>
			</view>
			<!-- 返程 -->
			
			<!-- 去程 -->
			<view v-if="planInfo&&planInfo.is_return_trip==0" class="u-skeleton-fillet">
				<view class="row-center" style="margin: 10px 0 0 12px;color: #000000;font-size: 15px;font-weight: 600;height: 30px;">
					<!-- <view class="go-item" >
						去
					</view> -->
					<text>{{planInfo.date_desc}}</text>
					<text style="margin: 0 8px;">{{planInfo.date_desc_week}} {{planInfo.dp_time}}</text>
					<text v-if="planInfo.plan_type==1||planInfo.plan_type==3">发车</text>
					<text v-else>前乘车</text>
				</view>
				<view class="row-center" style="margin:10px 12px;font-size: 16px;font-weight: 600;">
					<view style="max-width: 150px" class="line-ellipsis">{{planInfo.origin}}</view>
					<text class="iconfont iconchufadaodaxiao" style="margin: 0 5px;"></text>
					<view style="max-width: 150px" class="line-ellipsis">{{planInfo.destination}}</view>
				</view>
			</view>
			<!-- 去程 -->
			
			<view v-if="planInfo&&planInfo.plan_type==3&&planInfo.is_must==0" class="row-center u-skeleton-rect" style="margin: 5px 12px;color: #b9b9b9;">
				如预约失败，系统自动全额退款
			</view>
			<view v-else-if="planInfo&&planInfo.plan_type==3&&planInfo.is_must==1" class="row-center u-skeleton-rect" style="margin: 5px 12px;color: #b9b9b9;">
				已众筹拼车成功，发车前24小时不允许退票
			</view>
		<!-- 	<view v-else class="row-center u-skeleton-rect" style="margin: 5px 12px;color: #b9b9b9;">
				发车前24小时不允许在线退票
			</view> -->
		</view>
		
	
		
		<!-- 乘客  需要实名认证-->
		<view v-if="planInfo&&planInfo.is_passenger" class="column u-skeleton u-skeleton-fillet" style="background-color: #FFFFFF;width: 95%; margin: 10px;border-radius: 5px;">
			<view class="" style="margin: 10px;">
				<text style="color: #000000;font-size: 16px;">乘客</text> <text style="margin-left: 5px;font-size: 14px;color: #919191;">(每单限购{{planInfo.per_buy_num}}张)</text>
			</view>
			<view @click="passengerShow=true" v-if="passengerList&&!passengerList.length" class="" style="border-radius: 5px;height: 35px;line-height: 35px;color: #FFFFFF;margin: 10px;background-color: #FC4141;text-align: center;">
				<view><text class="iconfont iconkuaidiyuan-xianxing"></text>添加乘客</view>
			</view>
			<view v-else  style="display: flex;flex-flow: wrap;margin: 0 12px;">
				<view @click="selectPassenger(index)"  :class="item.check?'in-active':'no-active'" v-for="(item,index) in passengerList" :key="item.id" style="">
					<text>{{item.name}}</text>
					<view v-if="item.check" class="gou">
						<text class="iconfont iconzhengquewancheng" style="font-size: 10px;"></text>
					</view>
					<text style="display: none;">{{flag}}</text>
				</view>
				
	
				<view @click="passengerShow=true" class="no-active" style="">
					<text class="iconfont iconjia" style="font-size: 12px;"></text>更多
				</view>
			</view>
			
			
			<view class="">
				
				<view v-if="item.check" class="" v-for="(item, index) in passengerList" :key=index>
					<view class="row-center" style="margin: 5px 12px;">
						<text @click="delectPassenger(index)" class="iconfont iconshanchu2" style="color: #ff0004;margin: 0 10px 0 5px;"></text>
						<text style="font-size: 14px;color: #000000;font-weight: 600;width: 90px;">{{item.name}}</text>
						<text style="color: #909090;font-size: 12px;margin: 0 5px;margin-right: 32px;">{{item.id_card.substr(0,4) + "**********" + item.id_card.substr(14),}}</text>
						<view class="" style="width: 80px;height: 20px;line-height: 20px;font-size: 12px;background-color: #e4f4ff;color: #b5cdff;text-align: center;margin-right: 10px;">
							{{item.type==1?'成人票':'儿童票'}}
						</view>
						<text  @click="editPassenger(item)"  class="iconfont iconbianji2" style="margin-left: auto;font-size: 18px;color: #007AFF;"></text>
					
					</view>
					<view v-if="index!=(passengerList.length-1)" class="separation-line" style="margin: 12px;">
						
					</view>
				</view>
							
				
			</view>
		   
		<!--   <view @click="childShow=true" class="row-center"  style="margin: 5px 12px;">
		   	  <text style="color: #626262;margin-right: 8px;font-size: 12px;">免费携童</text>
			  <text style="color: #a2a2a2;font-size: 12px;">怀抱婴儿可免费申请，无座位</text>
			  <text class="iconfont iconright" style="color: #007AFF;margin-left: auto;"></text>
		   </view> -->
		   <view class="dashed_line"> </view>
		   <view class="row-center"  style="margin: 5px 12px;">
		   	  <text style="color: #000000;margin-right: 12px;">联系电话</text>
			  <text style="color: #000000;">{{userInfo?userInfo.phone:''}}</text>
		   </view>
		</view>
		<!-- 乘客  需要实名认证-->
		

        <!-- 乘客  不需要实名认证-->
		<view v-else class="column u-skeleton u-skeleton-fillet" style="background-color: #FFFFFF;width: 95%; margin: 10px;border-radius: 5px;">
			<view class="" style="margin: 10px;">
				<text style="color: #000000;font-size: 16px;">乘客</text> <text style="margin-left: 5px;font-size: 14px;color: #919191;">(每单限购{{planInfo.per_buy_num}}张)</text>
			</view>
		   <view class="row-center">
		   	<image src="http://qiniu.suxuvip.cn/%E4%BA%BA%E8%84%89.png" mode="" style="width: 25px;height: 25px;margin: 5px 0 15px 12px;"></image>
			<view class="display-flex-column" style="margin-left: 15px;">
				<text style="font-weight: 600;">乘车人数</text>
				<text style="font-size: 12px;color: #a2a2a2;">无需实名登记</text>
			</view>
			<u-number-box @change="peopleChange" :min="1"  :inputWidth="100" :inputHeight="60" color="#007AFF" style="margin-left: auto;margin-right: 12px;"></u-number-box>

		   </view>
		   <view class="dashed_line"> </view>
		   <view class="row-center"  style="margin: 5px 12px;">
		   	  <text style="color: #000000;margin-right: 12px;">联系电话</text>
		   			  <text style="color: #000000;">{{userInfo?userInfo.phone:''}}</text>
		   </view>
		</view>
		<!-- 乘客  不需要实名认证-->
		
		
		
		<!-- 优惠券 -->
		<view  @click="couponShow=true" class="row-center u-skeleton u-skeleton-fillet" style="background-image: linear-gradient(to right,#ffffff, #fffff0);width: 95%; margin: 10px;border-radius: 5px;">
			<!-- <view class="iconfont iconyouhuiquan-copy" style="color: #007AFF;margin: 15px 10px;">
			</view> -->
			<image src="http://qiniu.suxuvip.cn/youhuiquan.png" mode="" style="width: 25px;height: 25px; margin: 10px;"></image>
			<text style="font-size: 16px;font-weight: 500;color: #000000;">优惠券</text>
			<text style="margin-left: auto;color: #3d3d3d;">{{coupon_title?coupon_title:'请选择'}}</text>
			<text class="iconfont iconright" style="margin: 0 12px;"></text>
		</view>
		<!-- 优惠券 -->
		
		
		
		<view class="footer">
			<view class="" style="color: #FC4141;">
				￥<text style="font-size: 22px;">{{totalPrice}}</text>
			</view>
		<!-- 	<view @click="orderDetailShow=!orderDetailShow" class="row-center" style="margin-left: auto;margin-right: 15px;color: #6b6b6b;">
				<view>明细</view>
				<text class="iconfont iconup"></text>
			</view> -->
			<view @click="goPay()" class="pay-button" >
				立即付款
			</view>
		</view>
		<u-popup v-model="passengerShow" mode="bottom" @close="passengerShow=false" :border-radius="14" height="650" :closeable="true" >
			<view style="margin-top: 10px;margin-left: 10px;">
				<view class="" style="font-weight: 600;font-size: 18px;">
					选择乘客
				</view>
				<navigator url="/pages/add_passenger/index">
					<view class="" style="border-radius: 20px;height: 35px;line-height: 35px;width: 90%;color: #FC4141;margin: 15px;background-color: #e5f9ff;text-align: center;">
						<text class="iconfont iconjia" style="margin-right: 5px;"></text> 新增乘客
					</view>
				</navigator>
				
				<scroll-view class="" scroll-y="true" style="height: 400rpx;">
					
					<view  class="" v-for="(item, index) in passengerList" :key="index">
						<view class="row-center" style="margin: 5px 12px;">
							<text @click="editPassenger(item)"  class="iconfont iconbianji2" style="font-size: 25px;color: #FC4141;margin-right: 15px;"></text>
							<text style="font-size: 14px;color: #000000;font-weight: 600;width: 70px;">{{item.name}}</text>
							<text style="color: #909090;font-size: 12px;margin: 0 5px;margin-right: 25px;">{{item.id_card.substr(0,4) + "**********" + item.id_card.substr(14),}}</text>
							<view class="" style="width: 40px;height: 20px;background-color: #e4f4ff;color: #b5cdff;text-align: center;margin-right: 10px;">
								{{item.type==1?'成人':'儿童'}}
							</view>
							<view @click="selectPassenger(index)"  v-if="item.check" class="iconfont iconzhengqueshixin" style="margin-left: 12px;font-size: 25px;color: #FC4141;">
								
							</view>
							<view @click="selectPassenger(index)"  v-else class="iconfont iconcheckboxweixuanzhongda" style="margin-left: 12px;font-size: 25px;color: #FC4141;">
								
							</view>
						
						</view>
						<view v-if="index!=(passengerList.length-1)" class="separation-line" style="margin: 12px;">
							
						</view>
					</view>
								
					
				</scroll-view>
				
			</view>
		</u-popup>	
		
		<!-- 优惠券弹窗 -->
		<u-popup mode="bottom" v-model="couponShow" @close="couponShow=false" :safe-area-inset-bottom="true" :border-radius="20" height="500" :closeable="true">
			<view class="content" style="background: #f7f7f7;height: 100%;">
				<scroll-view scroll-y="true" v-if="couponList.length">
					<view style="padding: 20px 0;">
						<view v-for="(item,index) in couponList" :key="index">
							<view class="jingdong">
								<view class="left">
									<view class="sum">
										￥
										<text class="num">{{item.coupon_price}}</text>
									</view>
										<view class="type" v-if="item.use_min_price > 0">满{{item.use_min_price}}元可用</view>
									<view class="type" v-else>无门槛券</view>
								</view>
								<view class="right" style="flex:1">
									<view class="top">
										<view class="title">
											<text class="tag">现金券</text>
											<text>{{item.coupon_title}}</text>
										</view>
										<view class="bottom">
											<view class="date u-line-1" v-if="item.coupon_time">领取后{{item.coupon_time}}天内可用</view>
											<view class="date u-line-1" v-else>{{ item.start_time ? item.start_time + "-" : ""}}{{ item.end_time }}</view>
											<view style="margin-left: auto;" class="immediate-use" v-if="!item.is_use" @click="useCoupon(item.id, item)">立即使用</view>
											<view  style="margin-left: auto;" class="on-use" v-else @click="useCoupon(item.id,item)">不使用</view>
										</view>
									</view>
								</view>
							</view>
		
						</view>
					</view>
				</scroll-view>
				<view v-else style="font-size: 20px;color: #606266;margin-top: 100px;">暂无优惠券</view>
			</view>
		</u-popup>
		<!-- 优惠券弹窗 -->

        <!-- 明细弹窗 -->
		<u-popup v-if="planInfo" mode="bottom" v-model="orderDetailShow" @close="orderDetailShow=false" :safe-area-inset-bottom="true" round="5" height="500" zIndex="1" >
			<view class="display-flex-column" style="background: #f7f7f7;height: 100%;">
				<view class="row-center" style="margin: 15px 12px;">
					<text class="dot" style=" background: #bcc0c8;"></text>
					<text style="margin: 0 12px;font-size: 16px;color: #000000;font-weight: 600;">成人票</text>
					<text style="margin-left: auto;margin-right: 12px;font-weight: 600;">￥{{planInfo.normal_price}} x {{adultTicketNum}} 张</text>
				</view>
				<view class="separation-line" style="margin: 0 12px;"></view>
				<view class="row-center" style="margin: 15px 12px;">
					<text class="dot" style=" background: #bcc0c8;"></text>
					<text style="margin: 0 12px;font-size: 16px;color: #000000;font-weight: 600;">儿童票</text>
					<text v-if="planInfo.is_passenger" style="margin-left: auto;margin-right: 12px;font-weight: 600;">￥{{planInfo.normal_price*0.5}} x {{childTicketNum}} 张</text>
					<text v-else style="color: #9d9d9d;margin-left: auto;margin-right: 12px">该班次不支持购买儿童票</text>
				</view>
				<view class="separation-line" style="margin: 0 12px;"></view>
				<view class="row-center" style="margin: 15px 12px;">
					<text class="dot" style=" background: #bcc0c8;"></text>
					<text style="margin: 0 12px;font-size: 16px;color: #000000;font-weight: 600;"
					>优惠券<text v-if="coupon_title" style="font-size: 10px;color: #b1b1b1;font-weight: 300;">（{{coupon_title}}）</text>
					</text>
					<text style="margin-left: auto;margin-right: 12px;font-weight: 600;">￥{{couponMoney}} </text>
				</view>
			</view>
		</u-popup>
		<!-- 明细弹窗 -->	
		<u-popup v-model="childShow" @close="childShow=false" width="600" mode="center" round="8" >
			<view class="row-center">
				<view class="display-flex-column" style="align-items: center; margin: 35px 0 20px 0;width: 50%;">
					<image src="http://qiniu.suxuvip.cn/ertong.png" style="width: 70px;height:70px;margin-bottom: 30px;" mode=""></image>
					<view class="" style="font-size: 16px;color: #000000;">
						半价，有座
					</view>
					<view class="" style="color: #949494;font-size: 11px;margin: 8px 0 15px 0;">
						1.2米以下
					</view>
					<view @click="(passengerShow=true ,childShow=false)" style="line-height: 25px;height: 25px;border-radius: 4px;background-color: #007AFF;text-align: center;color: #FFFFFF;padding: 0 8px;">
						购买
					</view>
				</view>
				<view class="display-flex-column" style="align-items: center; margin: 35px 0 20px 0;width: 50%;">
					<image src="http://qiniu.suxuvip.cn/%E5%A5%B6%E7%93%B6.png" style="width: 65px;height: 65px;margin-bottom: 30px;" mode=""></image>
					<view class=""style="font-size: 16px;color: #000000;">
						免费，无座
					</view>
					<view class=""  style="color: #949494;font-size: 11px;margin: 8px 0 15px 0;">
						怀抱婴儿
					</view>
					<view @click="(applyChildShow=true,childShow=false)" style="line-height: 25px;height: 25px;border-radius: 4px;background-color: #007AFF;text-align: center;color: #FFFFFF;padding: 0 8px;">
						申请
					</view>
				</view>
			</view>
		</u-popup>
	
		<!-- 申请儿童票 -->
		<u-popup mode="bottom" v-model="applyChildShow" :safe-area-inset-bottom="true"  height="600" zIndex="100" >
			<view class="row-center" style="margin: 10px;">
				<view @click="childCancel">取消</view>
				<view  @click="childComfirm" style="margin-left: auto;color: #007AFF;">确定</view>
			</view>
			<view class="line"></view>
			<view class="" style="margin: 10px;text-align: center;color: #000000;">
				携童票占车总座位数的10%，此班次可申请<text style="margin: 0 1px;color: #ff1100;">{{planInfo.surplus_child_num}}</text>张
			</view>
			<view class="row-center" style="margin: 15px;border: 1px solid #e2e2e2;padding: 8px;">
				<view class="display-flex-column">
					<text style="color: #000000;">携童票</text>
					<text style="font-size: 10px;color: #919191;">免费申请，无座位</text>
				</view>
					<u-number-box @change="peopleChange" :min="0" :max="planInfo.surplus_child_num" v-model="childNum" :input-width="100" :input-height="60" color="#007AFF" style="margin-left: auto;margin-right: 12px;"></u-number-box>
			</view>
			<view class="" style="margin: 15px;color: #474747;font-size: 12px;">
				<view class="" >
					携童票说明：
				</view>
				<view class="">
					1、怀抱婴儿可免费申请携童票，无座位；身高为1.2米以下的的儿童，可购买半价儿童票（需填写有效身份证件信息）。
				</view>
				<view class="">
					2、因儿童占班车的总座位数有相关规定，所有如需携童乘车，需申请携童票。 
				</view>
				<view class="">
					3、如果没有申请携童票，当乘车儿童数达到相关规定时，运输方有权拒绝乘客乘车。
				</view>
			</view>
		</u-popup>
		<!-- 申请儿童票 -->	
		<u-popup v-model="rollShow" width="600" mode="center" :mask-close-able="false" border-radius="8" :mask-custom-style="background">
			<view style="margin: 15px 0;text-align: center;font-size: 16px;color: #000000;font-weight: 600;">
				流水班须知
			</view>
			<view class="" style="padding: 0 15px;">
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>1、</text><text>此班次是流水班次，发车形式为滚动发车</text>
				</view>
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>2、</text><text>请前往线路起始点乘车，以防误车</text>
				</view>
				<view class="row-center" style="margin:15px; align-items: flex-start;">
					<text>3、</text><text>禁止携带宠物上车</text>
				</view>
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>4、</text><text>禁止携带易燃易爆等违禁物品上车</text>
				</view>
			</view>
			<view class="popup-button"  @click="rollShow=false">
				我知道了
			</view>
		</u-popup>
	
		<u-popup v-model="bookingShow" width="600" mode="center" :mask-close-able="false" border-radius="8" :mask-custom-style="background">
			<view style="margin: 15px 0;text-align: center;font-size: 16px;color: #000000;font-weight: 600;">
				预约班通知
			</view>
			<view class="" style="padding: 0 15px;">
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>1、</text><text>此班次为预约班次，需预约人数达到规定人数（通常15人）视为发车成功</text>
				</view>
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>2、</text><text>当预约人数未达到规定人数即为发车失败，系统会自动为您取消订单</text>
				</view>
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>3、</text><text>当发车成功时，系统会发送预约成功短信</text>
				</view>
				<view class="row-center" style="margin:15px; align-items: flex-start;">
					<text>4、</text><text>禁止携带宠物上车</text>
				</view>
				<view class="row-center" style="margin: 15px; align-items: flex-start;">
					<text>5、</text><text>禁止携带易燃易爆等违禁物品上车</text>
				</view>
			</view>
			<view class="popup-button"  @click="bookingShow=false">
				我知道了
			</view>
		</u-popup>
		
		<payment :payMode="cartArr" :pay_close="pay_close" :isCall="true" :totalPrice="totalPrice.toString()"
			@changePayType="changePayType" @onChangeFun="onChangeFun"></payment>
	
		<u-action-sheet :list="daList" @click="daClick" v-model="daShow"></u-action-sheet>
		
		<u-toast ref="uToast" />
		
		
		<u-skeleton :loading="loading" :animation="true" bgColor="linear-gradient(#0c79ff, #ffffff)"></u-skeleton>
		<u-picker mode="selector" @confirm="selctOnStop" v-model="onShow"  :range="on_stop_arr" range-key="stop_name"></u-picker>
		<u-picker mode="selector" @confirm="selctOffStop"  v-model="offShow"  :range="off_stop_arr" range-key="stop_name"></u-picker>
	</view>
</template>


<script>
    import {getLinePlanDetail} from '@/api/bus'
	import {getPassengerList,getUserInfo} from '@/api/user'
	import {getUserCoupons} from '@/api/api'
	import {orderBusConfirm,orderBusCreate,orderBusPay} from '@/api/order'
	import payment from '@/components/payment';
	import {
			mapGetters
		} from "vuex";
	import {
		toLogin
	} from '@/libs/login.js';
	import {
			openPaySubscribe
		} from '@/utils/SubscribeMessage.js';
	var util = require('@/common/js/util.js');
	var _getDiffDate = util.getDiffDate;
	var _addDay = util.addDay;
	var _dateDiff = util.dateDiff;
	var _parseDate = util.parseDate;
	var _formatDate = util.formatDate
	var _formatFloat = util.formatFloat
	var _add = util.add
	var _mul = util.mul
   
	export default {
		components:{
			payment
		},
		computed: mapGetters(['isLogin']),
		
		data() {
			return {
				onShow:false,
				offShow:false,
				from:'',
				childNum:0,
				applyChildShow:false,
				childShow:false,
				background:{background: 'rgba(0, 0, 0, 0.85)'},
				bookingShow:false,
				rollShow: false,
				isRefresh:false,
				disableFlag:false,
				orderDetailShow:false,
				planId: '',
				planInfo:'',
				loading: true, // 是否显示骨架屏组件
				passengerShow: false,
				list: [{
					name: '途经站点'
				}, {
					name: '预订须知'
				}, {
					name: '退改须知'
				}],
				// 因为内部的滑动机制限制，请将tabs组件和swiper组件的current用不同变量赋值
				current: 0, // tabs组件的current值，表示当前活动的tab选项
				swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
				passengerList:[],
				flag:0,
				couponShow: false,
				couponMoney: 0.00,
				currentCouponIndex: -1,
				couponList: [],
				coupon_id: 0,
				coupon_title: '',
				useIntegral: false, //是否使用积分
				integral: 0,
				userInfo: {},
				couponMoney: 0.00,
				totalPrice: 0,
				on_stop_arr:[],
				off_stop_arr:[],
				on_stop_id: '',
				off_stop_id: '',
				on_stop_name: '',
				off_stop_name: '',
				childTicketNum: 0,
				adultTicketNum:0,
				order_source: 1, //订单来源
				c_message: '', //用户留言
				peopleNum:1,
				daList: [{
					text: '查看实景图',
					color: '#26a2ff',
					fontSize: 28
				},{
					text: '导航去这里',
					color: '#26a2ff',
					fontSize: 28
				}],
				daShow: false,
				currentStop: {},
				opacity1:true,
				opacity2:true,
				pay_close: false,
				payType: 'weixin', //支付方式
				//支付方式
				cartArr: [{
						"name": "微信支付",
						"icon": "iconzhifu-weixinzhifu",
						value: 'weixin',
						title: '使用微信快捷支付',
						payStatus: 1,
					},
					{
						"name": "支付宝支付",
						"icon": "icon-zhifubao",
						value: 'alipay',
						title: '使用线上支付宝支付',
						payStatus: 1,
					},
					{
						"name": "余额支付",
						"icon": "iconyue",
						value: 'yue',
						title: '可用余额:',
						payStatus: 1,
					},
				],
				integralRatio: "0",
	            orderKey: "",
				invoice_func: false,
				invTitle: '不开发票',
				special_invoice: false,
			}
		},
		onLoad(option) {	
			// #ifdef H5
			this.from = this.$wechat.isWeixin() ? 'weixin' : 'weixinh5'
			// #endif
			// #ifdef MP
			this.from = 'routine'
			// #endif
			// #ifdef MP-TOUTIAO
			this.from = 'routine_toutiao'
			// #endif
			switch (option.plan_type){
				case '2':
				    this.rollShow = true 
					break;
				case '3':
				    this.bookingShow = true
					break;
				default:
					break;
			}
			this.on_stop_id = option.on_stop_id
			this.off_stop_id = option.off_stop_id
			this.on_stop_name = option.on_stop_name
			this.off_stop_name = option.off_stop_name

			this.initRegularDetail(option.plan_id)
			this.planId = option.plan_id
			// if(this.isLogin == true){	
			// 	this.getConfirm(option.plan_id);
			
			// }
		},
		onReady() {
			
		},
		// onBackPress(){
		// },
		onShow() {
			if(this.isLogin == true){
				var that = this;
				var pages = getCurrentPages();
				var currPage = pages[pages.length - 1]; //当前页面
				// #ifdef MP
				let res = currPage.data.isRefresh;
				//#endif
				// #ifdef H5
				let res = currPage.isRefresh;
				//#endif
				// #ifdef  APP-PLUS
				let res = currPage.isRefresh;
				//#endif	
				if(res) {
					that.initPassengerList()
					that.isRefresh = false
				}
				that.initPassengerList()
				
				this.getConfirm(this.planId);
			} else {
				toLogin()
			}
		},
		methods:{
			selctOnStop(item){
				this.on_stop_id = this.on_stop_arr[item[0]].line_stop_id
				this.on_stop_name = this.on_stop_arr[item[0]].stop_name
				this.computePrice()
			
			},
			selctOffStop(item){
				this.off_stop_id = this.off_stop_arr[item[0]].line_stop_id
				this.off_stop_name = this.off_stop_arr[item[0]].stop_name
				this.computePrice()
				
			},
			getLinePrice(){
				var priceList = this.planInfo.line_price
				if(this.on_stop_id&&this.off_stop_id){
					return priceList.find((res)=>this.on_stop_id==res.on_stop_id&&this.off_stop_id==res.off_stop_id ).price
				} else {
					return 0;
				}
			},
			payClose: function() {
				this.pay_close = false;
			},
			goPay() {
				if (!(this.on_stop_id&&this.off_stop_id)) {
					return this.$util.Tips({title: '请先选择上下车点！'});
				} 
				// #ifdef  MP-TOUTIAO
				 this.payType = 'toutiaoweixin';
				//#endif	
				// this.pay_close = true;
				
				
				this.SubOrder();
			},
			changePayType(type) {
				this.payType = type
				// this.computedPrice()

			},
			/**
			 * 事件回调
			 *
			 */
			onChangeFun: function(e) {
				let opt = e;
				let action = opt.action || null;
				let value = opt.value != undefined ? opt.value : null;
				action && this[action] && this[action](value);
			},
			payCheck(type) {
				
				this.payType = type;
				this.SubOrder();
			},
			SubOrder: function(e) {
				let that = this,
					data = {};
	            var isSelectPassenger=false;
				var passList = [];
				var passNum = 0;
					
				if(that.planInfo.is_passenger){
					that.passengerList.forEach(function(item){
						if(item.check){
							isSelectPassenger = true
							passNum++
							passList.push(item)
						}
					})
				}
				// that.planInfo.line_stations.forEach(function(item,index){
				// 	if(index==0){
				// 		that.on_stop_id = item.line_stop_id
				// 	}
				// 	if(index==(that.planInfo.line_stations.length -1)){
				// 		that.off_stop_id = item.line_stop_id
				// 	}
				// })
				if (!that.payType) return that.$util.Tips({
					title: '请选择支付方式'
				});
				
				if (!isSelectPassenger&&that.planInfo.is_passenger) {
					return that.$util.Tips({title: '请选择乘客'});
				}  else if(that.planInfo.stock< passNum && that.planInfo.is_passenger){
					return that.$util.Tips({title: '库存不足'});
				}
				else if(that.planInfo.stock< that.peopleNum && !that.planInfo.is_passenger){
					return that.$util.Tips({title: '库存不足'});
				}
				data = {
					plan_id: that.planInfo.plan_id,
					line_id: that.planInfo.line_id,
					formId: '',		
					couponId: that.coupon_id,
					useIntegral: that.useIntegral,
					payType: that.payType,
					'from': that.from,
					passenger_list: passList,
					on_stop_id: that.on_stop_id,
					off_stop_id: that.off_stop_id,
					people_num: that.peopleNum,
					child_num: that.childNum
				};
				if (data.payType == 'yue' && parseFloat(that.userInfo.now_money) < parseFloat(that.totalPrice))
					return that.$util.Tips({
						title: '余额不足！'
					});
				uni.showLoading({
					title: '订单支付中'
				});
				// #ifdef MP-WEIXIN
				
				openPaySubscribe().then(() => {
				
					that.payment(data);
				});
				// #endif
				// #ifdef MP-TOUTIAO
				that.payment(data);
				// #endif
				// #ifndef MP
				that.payment(data);
				// #endif
			},
			
			payment: function(data) {
				let that = this;
				orderBusCreate(that.orderKey, data).then(res => {
					var order = res.data.order
					orderBusPay({
						uni: order.order_id,
						// #ifdef MP-WEIXIN
						'from': 'routine',
						paytype: that.payType,
						// #endif
						// #ifdef MP-TOUTIAO
						'from': 'routine_toutiao',
						paytype: 'toutiaoweixin',
						// #endif
			
						// #ifdef H5
						quitUrl: location.port ? location.protocol + '//' + location.hostname + ':' + location
							.port +
							'/pages/users/order_details/index?order_id=' + order.order_id : location.protocol +
							'//' + location.hostname +
							'/pages/users/order_details/index?order_id=' + order.order_id
						// #endif
						// #ifdef APP-PLUS
						quitUrl: '/pages/users/order_detail/index?order_id=' + order.order_id
						// #endif
					}).then(res => {
						// let jsConfig = res.data.result.jsConfig;
						uni.hideLoading();
						let status = res.data.status,
							orderId = res.data.result.orderId,
							jsConfig = res.data.result.jsConfig,
							goPages = '/pages/pay_success/index'
						switch (status) {
								case 'ORDER_EXIST':
								case 'EXTEND_ORDER':
								case 'PAY_ERROR':
									uni.hideLoading();
									return that.$util.Tips({
										title: res.msg
									}, {
										tab: 5,
										url: goPages
									});
									break;
								case 'SUCCESS':
									uni.hideLoading();
									if (that.BargainId || that.combinationId || that.pinkId || that.seckillId)
										return that.$util.Tips({
											title: res.msg,
											icon: 'success'
										}, {
											tab: 4,
											url: goPages
										});
									return that.$util.Tips({
										title: res.msg,
										icon: 'success'
									}, {
										tab: 5,
										url: goPages
									});
									break;
								case 'TOUTIAO_WECHAT_PAY':
									uni.requestPayment({
										provider: 'toutiao',
										orderInfo: jsConfig,
										service: 5,
										success: (e) => {
											uni.hideLoading();
											// #ifdef MP-TOUTIAO
											if(e.code!=0){
												return that.$util.Tips({
													title: '取消支付'
												}, {
													tab: 5,
													url: goPages + '&status=2'
												});
											} else{
												let url = goPages;
												uni.showToast({
													title: "支付成功"
												})
												setTimeout(res => {
													uni.redirectTo({
														url: url
													})
												}, 2000)
											}
											// #endif
											
											// #ifndef MP-TOUTIAO
											let url = goPages;
											uni.showToast({
												title: "支付成功"
											})
											setTimeout(res => {
												uni.redirectTo({
													url: url
												})
											}, 2000)
											// #endif
											
											
										},
										fail: (e) => {
											
											uni.hideLoading();
											return that.$util.Tips({
												title: '取消支付'
											}, {
												tab: 5,
												url: goPages + '&status=2'
											});
										},
										complete: () => {
											
											uni.hideLoading();
											uni.hideLoading();
											return that.$util.Tips({
												title: '取消支付'
											}, {
												tab: 5,
												url: goPages + '&status=2'
											});
										},
									});
								
								case 'WECHAT_PAY':
									that.toPay = true;
									// #ifdef MP
									/* that.toPay = true; */
									uni.requestPayment({
										timeStamp: jsConfig.timestamp,
										nonceStr: jsConfig.nonceStr,
										package: jsConfig.package,
										signType: jsConfig.signType,
										paySign: jsConfig.paySign,
										success: function(res) {
											uni.hideLoading();
											return that.$util.Tips({
												title: '支付成功',
												icon: 'success'
											}, {
												tab: 5,
												url: goPages
											});
										},
										fail: function(e) {
											uni.hideLoading();
											return that.$util.Tips({
												title: '取消支付'
											}, {
												tab: 5,
												url: goPages + '&status=2'
											});
										},
										complete: function(e) {
											uni.hideLoading();
											//关闭当前页面跳转至订单状态
											if (res.errMsg == 'requestPayment:cancel') return that.$util
												.Tips({
													title: '取消支付'
												}, {
													tab: 5,
													url: goPages + '&status=2'
												});
										},
									})
									// #endif
									// #ifdef H5
									this.$wechat.pay(res.data.result.jsConfig).then(res => {
										return that.$util.Tips({
											title: '支付成功',
											icon: 'success'
										}, {
											tab: 5,
											url: goPages
										});
									}).catch(res => {
										if (!this.$wechat.isWeixin()) {
											uni.redirectTo({
												url: goPages +
													'&msg=支付失败&status=2'
											})
										}
										if (res.errMsg == 'chooseWXPay:cancel') return that.$util.Tips({
											title: '取消支付'
										}, {
											tab: 5,
											url: goPages + '&status=2'
										});
									})
									// #endif
									// #ifdef APP-PLUS
									uni.requestPayment({
										provider: 'wxpay',
										orderInfo: jsConfig,
										success: (e) => {
											let url = goPages;
											uni.showToast({
												title: "支付成功"
											})
											setTimeout(res => {
												uni.redirectTo({
													url: url
												})
											}, 2000)
										},
										fail: (e) => {
											console.log(123,e)
											uni.showModal({
												content: "支付失败",
												showCancel: false,
												success: function(res) {
													if (res.confirm) {
														uni.switchTab({
															url: '/pages/index/index'
														})
													} else if (res.cancel) {
														console.log('用户点击取消');
													}
												}
											})
										},
										complete: () => {
											uni.hideLoading();
										},
									});
									// #endif
									break;
								case 'PAY_DEFICIENCY':
									uni.hideLoading();
									//余额不足
									return that.$util.Tips({
										title: res.msg
									}, {
										tab: 5,
										url: goPages + '&status=1'
									});
									break;
								case "WECHAT_H5_PAY": //公众号
									uni.hideLoading();
									that.$util.Tips({
										title: '订单创建成功'
									}, {
										tab: 5,
										url: goPages + '&status=0'
									});
									setTimeout(() => {
										location.href = res.data.result.jsConfig.mweb_url;
									}, 100);
									break;
						
								case 'ALIPAY_PAY':
									//#ifdef H5
									if (this.from === 'weixin') {
										uni.redirectTo({
											url: `/pages/users/alipay_invoke/index?id=${orderId}&pay_key=${res.data.result.pay_key}`
										});
									} else {
										uni.hideLoading();
										that.formContent = res.data.result.jsConfig;
										that.$nextTick(() => {
											document.getElementById('alipaysubmit').submit();
										})
									}
									//#endif
									// #ifdef MP
									uni.navigateTo({
										url: `/pages/users/alipay_invoke/index?id=${orderId}&link=${jsConfig.qrCode}`
									});
									// #endif
									// #ifdef APP-PLUS
									uni.requestPayment({
										provider: 'alipay',
										orderInfo: jsConfig,
										success: (e) => {
											uni.showToast({
												title: "支付成功"
											})
									
											setTimeout(res => {
												uni.redirectTo({
													url: goPages
												})
											}, 2000)
						
										},
										fail: (e) => {
												'&msg=支付失败';
											uni.showModal({
												content: "支付失败",
												showCancel: false,
												success: function(res) {
													if (res.confirm) {
														uni.switchTab({
															url: '/pages/index/index'
														})
													} else if (res.cancel) {
														console.log('用户点击取消');
													}
												}
											})
										},
										complete: () => {
											uni.hideLoading();
										},
									});
									// #endif
									break;
							}
						
						
						// switch (that.payType) {
						// 	case 'weixin':
						// 		if (res.data.result === undefined) return that.$util.Tips({
						// 			title: '缺少支付参数'
						// 		});
						// 		// #ifdef MP
						// 		uni.requestPayment({
						// 			timeStamp: jsConfig.timestamp,
						// 			nonceStr: jsConfig.nonceStr,
						// 			package: jsConfig.package,
						// 			signType: jsConfig.signType,
						// 			paySign: jsConfig.paySign,
						// 			success: function(res) {
						// 				uni.hideLoading();
						// 				return that.$util.Tips({
						// 					title: res.msg,
						// 					icon: 'success'
						// 				}, () => {
						// 					//TODO
						// 					uni.navigateTo({
						// 						url: '/pages/pay_success/index'
						// 					});
						// 				});
						// 			},
						// 			fail: function(e) {
						// 				uni.hideLoading();
						// 				return that.$util.Tips({
						// 					title: '取消支付'
						// 				}, () => {
						// 					//TODO
						// 				});
						// 			},
						// 			complete: function(e) {
						// 				uni.hideLoading();
						// 				if (e.errMsg == 'requestPayment:cancel') return that.$util
						// 					.Tips({
						// 						title: '取消支付'
						// 					}, () => {
						// 						//TODO
						// 					});
						// 			},
						// 		});
						// 		// #endif
						// 		break;
						// 	case 'yue':
						// 		uni.hideLoading();
						// 		return that.$util.Tips({
						// 			title: res.msg,
						// 			icon: 'success'
						// 		}, () => {
						// 			//TODO
						// 			uni.navigateTo({
						// 				url: '/pages/pay_success/index'
						// 			});
						// 		});
						// 		break;
						// }
					}).catch(err => {
						uni.hideLoading();
						return that.$util.Tips({
							title: err
						}, () => {
						});
					})								
					}).catch(err => {
					uni.hideLoading();
					return that.$util.Tips({
						title: err
					});
				});
			},
			subOrder1:function(){
				if(this.disableFlag) return
				uni.showLoading({
				    title: '正在创建...'
				});
				
				this.disableFlag = true
				// 验证提交信息
				let that = this;
				var isSelectPassenger=false;
				var passList = [];
				var passNum = 0;
					
				that.passengerList.forEach(function(item){
					if(item.check){
						isSelectPassenger = true
						passNum++
						passList.push(item)
					}
				})
				
				// that.planInfo.line_stations.forEach(function(item,index){
				// 	if(index==0){
				// 		that.on_stop_id = item.line_stop_id
				// 	}
				// 	if(index==(that.planInfo.line_stations.length -1)){
				// 		that.off_stop_id = item.line_stop_id
				// 	}
				// })
					
		
					
					
				var tips = "";
				if (!isSelectPassenger&&that.planInfo.is_passenger) {
					tips = "请选择乘客";
				}  else if(that.planInfo.stock< passNum && that.planInfo.is_passenger){
					tips = "库存不足";
				}
				else if(that.planInfo.stock< that.peopleNum && !that.planInfo.is_passenger){
					tips = "库存不足";
				}
					
			
				if (tips) {
					that.$u.toast(tips)
					this.disableFlag = false
					
					return;
				} 
				this.disableFlag = false
						
				var sb_data = {
					plan_id: that.planInfo.plan_id,
					line_id: that.planInfo.line_id,
					c_message: that.c_message,
					use_integral: that.use_integral,
					order_source: 1,
					coupon_id: that.coupon_id,
					regular_id: that.planInfo.regular_id,
					pay_type: 1,
					pay_source: 1,
					use_integral: 0,
					passenger_list: passList,
					on_stop_id: that.on_stop_id,
					off_stop_id: that.off_stop_id,
					people_num: that.peopleNum,
					child_num: that.childNum
					
				}
				
				
				this.$u.api.V2CreateOrderBusNew(sb_data).then(res => {
					if(res.code == 0){
						uni.hideLoading()
						/**在小程序环境直接支付**/
						// #ifdef MP
						uni.showLoading({
						    title: '支付中...'
						});
						that.$u.api.payOrder({
							order_id: res.data.order_id,
							pay_type: 1
						}).then(res1 => {
							uni.hideLoading()
							uni.requestPayment({
								provider: 'weixin',
								orderInfo: res1.data.order.order_name,
								timeStamp: res1.data.param.timeStamp.toString(),
								nonceStr: res1.data.param.nonceStr,
								package: res1.data.param.package,
								signType: res1.data.param.signType,
								paySign: res1.data.param.paySign,
								success(res) {
									uni.navigateTo({
										url: '/pages/pay_success/index'
									});
								},
								fail(res) {
								},
								complete(res) {
									// that.$refs.uToast.show({
									// 	title: '支付失败',
									// 	type: 'error',
									// })
								}
							})
						})
						// #endif
					} else{
						uni.hideLoading()
						
						that.$u.toast('创建订单失败')
					}
				})
			},
			//登录成功
			
			/**
			 * 获取当前订单详细信息
			 * 
			 */
			getConfirm: function(planId) {
				let that = this;
				// return;
				orderBusConfirm({plan_id:planId}).then(res => {
					that.$set(that, 'userInfo', res.data.userInfo);
					that.$set(that, 'integral', res.data.userInfo.integral);
					that.$set(that, 'integralRatio', res.data.integralRatio);
					that.$set(that, 'orderKey', res.data.orderKey);
					that.$set(that, 'invoice_func', res.data.invoice_func);
					that.$set(that, 'special_invoice', res.data.special_invoice);
					//微信支付是否开启
					that.cartArr[0].payStatus = res.data.pay_weixin_open || 0
					//支付宝是否开启
					that.cartArr[1].payStatus = res.data.ali_pay_status || 0;
					//#ifdef MP
					that.cartArr[1].payStatus = 0;
					//#endif
					//余额支付是否开启
					that.cartArr[2].title = '可用余额:' + res.data.userInfo.now_money;
					that.cartArr[2].number = res.data.userInfo.now_money;
					that.cartArr[2].payStatus = res.data.yue_pay_status == 1 ? res.data.yue_pay_status : 0
					// if (res.data.offline_pay_status == 2) {
					// 	that.cartArr[3].payStatus = 0
					// } else {
					// 	that.cartArr[3].payStatus = 1
					// }
				}).catch(err => {
					return this.$util.Tips({
						title: err
					});
				});
			},
			
			peopleChange:function(e){
				this.peopleNum = e.value
				this.computePrice()
			},
			loginSuccess:function(data){
				if(data.flag == true){
					 this.initPassengerList()
				}else{
					
				}
				
			},
			initCoupon:function(line_id) {
				var that = this
				getUserCoupons(1,{
					line_id: line_id
				}).then(res => {
					that.couponList = res.data
					if(that.couponList.length >= 1){
						that.useCoupon(that.couponList[0]['id'],that.couponList[0])
					}
				})
			},
			initUserInfo:function() {
				var that = this
				getUserInfo().then(res => {
					that.userInfo = res.data
					that.integral = res.data.integral
				})
			},
			initRegularDetail:function(planId){
				var that = this
				getLinePlanDetail({plan_id: planId}).then(res => {
					this.loading = false
					this.planInfo = res.data
					that.planInfo.line_stations.forEach(function(item,index){
						/***不默认选择上下车点*/
						// if(index==0){
						// 	that.on_stop_id = item.line_stop_id
						// 	that.on_stop_name = item.stop_name
						// }
						// if(index==(that.planInfo.line_stations.length -1)){
						// 	that.off_stop_id = item.line_stop_id
						// 	that.off_stop_name = item.stop_name
						// }
						if(item.stop_type==1){
							that.on_stop_arr.push(item)
						}
						if(item.stop_type==2){
							that.off_stop_arr.push(item)
						}
					})
					
					if(this.isLogin==true){
						this.initPassengerList()
					}
					if(this.planInfo.stock <= 5){
						uni.showModal({
						    title: '温馨提示',
						    content: this.planInfo.stock?'当前班次座位数较少，还能购买'+ this.planInfo.stock+'张票，请尽快购买车票':'票已买完，请选择其他班次',
							showCancel: false,
							confirmText: '我已知晓',
						    success: function (res) {
						        if (res.confirm) {
						            // console.log('用户点击确定');
									// uni.navigateBack({
										
									// })
						        } else if (res.cancel) {
						           
						        }
						    }
						});
					}
				})
			},
			initPassengerList:function(){
				let that = this
				getPassengerList().then(res => {
					that.passengerList = res.data
					that.passengerList.forEach(function(res,index) {
						if(index==0){
							that.passengerList[index].check = true
						} else {
							that.passengerList[index].check = false
						}
					})	
					
					// that.initUserInfo()
					
					setTimeout(function(){
						that.planInfo.normal_price?that.computePrice():''
					},200)
					that.initCoupon(this.planInfo.line_id )
				})
			},
			
			selectPassenger:function(index){
				this.passengerList[index].check = !this.passengerList[index].check
				
				var passNum = 0;
				this.passengerList.forEach(function(res){
					if(res.check==true){
						passNum++
					}
				})
				
				

				if(passNum > this.planInfo.per_buy_num){
					this.passengerList[index].check = false
					uni.showModal({
					    title: '温馨提示',
					    content: '当前班次最多一次购买'+this.planInfo.per_buy_num+'张票',
						showCancel: false,
						confirmText: '我已知晓',
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					
					return
				} else if(passNum > this.planInfo.stock){
					this.passengerList[index].check = false
					uni.showModal({
					    title: '温馨提示',
					    content: this.planInfo.stock?'当前班次座位数不够了，只能购买'+ this.planInfo.stock+'张票':'票已买完，请选择其他班次',
						showCancel: false,
						confirmText: '我已知晓',
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					
					return
				} else{
					this.flag++
				}
				
				this.computePrice()
				
				
			},
			
			delectPassenger:function(index){
				this.passengerList[index].check = false
				this.flag++
				this.computePrice()
			},
			
			editPassenger:function(item){
				uni.navigateTo({
					url:'/pages/add_passenger/index?id='+item.id+'&id_card='+item.id_card+'&name='+item.name+'&phone='+item.phone+'&type='+item.type
				})
			},
			// tabs通知swiper切换
			tabsChange:function(index) {
				this.swiperCurrent = index;
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition:function(e) {
				let dx = e.detail.dx;
				this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish:function(e) {
				let current = e.detail.current;
				this.$refs.uTabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			},
		
			
			goPlanDetail(){
				uni.navigateTo({
					url: '/pages/bus/station/index?plan_id='+this.planId
				})
			},
			
			/**
			 * 使用优惠券
			 */
			useCoupon:function(coupon_id,item) {
				// if (this.totalPrice <= 0) {
				// 	this.$u.toast('请先选择乘坐乘客')
				// 	return
				// } 
				if(this.totalPrice<=0){
					return;
				}
				 if (this.useIntegral) {
						this.$u.toast('优惠券和积分不能同时使用')
				} else {
					if(this.totalPrice < item.use_min_price){
						this.$u.toast('不满足使用条件')
						return
					}
					this.couponList.forEach(res => {
						if (res.id == coupon_id) {
							res.is_use = !res.is_use
						} else {
							res.is_use = 0
						}
					})
					this.computePrice()
				}
			
			
			},
			
			computePrice:function() {
				var that = this;
				var planInfo = that.planInfo,
					currentCouponIndex = that.currentCouponIndex;
				var totalPrice = 0;
				// var price = planInfo.normal_price;
				var price = that.getLinePrice();
					// totalPrice = _formatFloat(peopleNum* price, 2);
				that.adultTicketNum = 0
				that.childTicketNum = 0
				console.log(1111,this.peopleNum)
				if(price&&planInfo.is_passenger){ 
					that.passengerList.forEach(function(item){
						
						// 成人票
						if(planInfo&&item.check&&item.type==1){
							totalPrice = _add(totalPrice,_formatFloat(price,2)) 
							that.adultTicketNum++
						}else if(planInfo&&item.check&&item.type==2){
							totalPrice = _add(totalPrice,_formatFloat(_mul(price,0.5),2))  
							that.childTicketNum++
						}
					})	
				} else if(price&&!planInfo.is_passenger) {
					that.adultTicketNum = that.peopleNum
					totalPrice = _formatFloat(_mul(price,that.peopleNum),2)
				}
				
				
					
				
			
				var originTotalPrice = totalPrice
			
				//重新计算
				totalPrice = that.computeWithCouponPrice(that, totalPrice) ;
				totalPrice = that.computeWithIntegralPrice(that, totalPrice);
				// totalPrice = that.computeWithFullReduction(that, totalPrice);
			         
			
				that.totalPrice = totalPrice
				
				
				
				that.couponMoney = originTotalPrice - totalPrice;
			},
			//重新计算 优惠券 积分等等
			computeWithCouponPrice:function(that, totalPrice) {
				var currentCoupon = that.couponList.find((element) => (element.is_use == 1));
				that.coupon_id = currentCoupon ? currentCoupon.id : 0
				that.coupon_title = currentCoupon ? currentCoupon.coupon_title : ''
				if (!currentCoupon) {
					return totalPrice;
				}
				var newPrice = totalPrice;
				newPrice = _formatFloat(totalPrice - currentCoupon.coupon_price, 2);
				return Number(newPrice) > 0 ? Number(newPrice) : _formatFloat(0, 2);
			},
			//重新计算 优惠券 积分等等
			computeWithIntegralPrice:function(that, totalPrice) {
				if (!that.useIntegral) {
					return totalPrice;
				}
				var newPrice = totalPrice;
				if (newPrice >= that.integral / 100) {
					newPrice = _formatFloat(newPrice - that.integral / 100, 2)
					that.integral = 0
				} else {
					newPrice = 0.01
					that.integral = (that.integral - newPrice * 100)
				}
			
			
				return Number(newPrice) > 0 ? Number(newPrice) : _formatFloat(0, 2);
			},
			
			
			
			
			lookStation:function(item){
				
				this.daShow = true
				this.currentStop = {
					lng: item.lng,
					lat: item.lat,
					stop_id: item.line_stop_id,
					id: item.id,
					stop_name: item.stop_name,
					images: item.image
				}
			},
			//导航
			daClick:function(e) {
				var that = this
				if(e==1){
					uni.openLocation({
						//​使用微信内置地图查看位置。
						latitude: parseFloat(that.currentStop.lat),
						longitude: parseFloat(that.currentStop.lng),
						name: that.currentStop.stop_name
					});
				} else {
					
				   that.currentStop.images.length?that.joinQun():that.$u.toast('该站点暂无站点图片')
				}
			},
			joinQun:function(){
				   // 预览图片
				   var that = this
				   uni.previewImage({
				   	urls: that.currentStop.images
				   });
			},
			childComfirm:function(){
				this.applyChildShow = false
			},
			childCancel:function(){
				this.childNum = 0
				this.applyChildShow = false
			}
				
		 }
		
	}
</script>

<style lang="scss" >
	page{
		 // background-image: linear-gradient(#0c79ff, #ffffff) !important;
		/* background:linear-gradient(#0c79ff, #ffffff); */
		background:#dedede
	}
	.main {
	    // background: linear-gradient(to bottom,#007AFF,#007AFF,#efeff4,#efeff4,#efeff4,#efeff4);
		height: 100%;
		padding-bottom: 80px;
	}
	.go-item {
		border-radius: 5px;
		background-color: #1f73d9;
		color: #FFFFFF;   
		 width: 20px; 
		 height: 20px;
		 text-align: center;
		 margin-right: 5px;
		 font-size: 12px;
		 line-height: 20px;
	}
	.back-item {
		border-radius: 5px;
		background-color: #ff5303;
		color: #FFFFFF;   
		 width: 20px; 
		 height: 20px;
		 text-align: center;
		 margin-right: 5px;
		 font-size: 12px;
		 line-height: 20px;
	}
	
	.no-active{
		width: 27%;
		height: 35px;
		border-radius: 5px;
		border: 1px solid #e5e5e5;
		margin: 0 15px 10px 0;
		text-align: center;
		line-height: 35px;
		position: relative;
	}
	.in-active{
		width: 27%;
		height: 35px;
		border-radius: 5px;
		border: 1px solid #FC4141;
		margin: 0 15px 10px 0;
		text-align: center;
		line-height: 35px;
		position: relative;
	}
	.gou {
		position: absolute;
		float: right;
		right: 0;
		background-color: #FC4141;
		width: 15px;
		height: 10px;
		line-height: 10px;
		bottom: 0;
		border-bottom-right-radius: 3px;
		border-top-left-radius: 5px;
		color: #ffffff;
	}
	.content {
		padding: 24rpx;
		text-align: center;
	}
	
	.jingdong {
		margin-top: 40rpx;
		width: 700rpx;
		height: auto;
		background-color: #ffffff;
		display: flex;
	
		.left {
			padding: 0 30rpx;
			background-color: #FC4141;
			text-align: center;
			font-size: 28rpx;
			color: #ffffff;
	
			.sum {
				/* margin-top: 50rpx; */
				font-weight: bold;
				font-size: 32rpx;
	
				.num {
					font-size: 80rpx;
				}
			}
	
			.type {
				//margin-bottom: 50rpx;
				font-size: 24rpx;
			}
		}
	
		.right {
			padding: 20rpx 20rpx 0;
			font-size: 28rpx;
	
			.top {
				border-bottom: 2rpx dashed #b1b1b1 ;
	
				.title {
					margin-right: 60rpx;
					line-height: 40rpx;
	
					.tag {
						padding: 4rpx 20rpx;
						background-color: #FC4141;
						border-radius: 20rpx;
						color: #ffffff;
						font-weight: bold;
						font-size: 24rpx;
						margin-right: 10rpx;
					}
				}
	
				.bottom {
					display: flex;
					margin-top: 20rpx;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 10rpx;
	
					.date {
						font-size: 20rpx;
						flex: 1;
					}
	
					.immediate-use {
						height: auto;
						padding: 0 20rpx;
						font-size: 24rpx;
						border-radius: 40rpx;
						line-height: 40rpx;
						color: #FC4141;
						border: 2rpx solid #FC4141;
						margin-left: 10px;
					}
	
					.on-use {
						height: auto;
						padding: 0 20rpx;
						font-size: 24rpx;
						border-radius: 40rpx;
						line-height: 40rpx;
						color: #bebdb6;
						border: 2rpx solid #bebdb6;
						margin-left: 10px;
					}
				}
			}
	
			.tips {
				width: 100%;
				line-height: 50rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 24rpx;
	
				.transpond {
					margin-right: 10rpx;
				}
	
				.explain {
					display: flex;
					align-items: center;
				}
	
			
			}
		}
	}
	
	
	.footer {
		display: flex;
		flex-wrap: wrap;
		width: 100%;
		height: 130rpx;
		background-color: #fff;
		padding: 0 10px 0 10px;
		font-size: 32rpx;
		color: #333;
		box-sizing: border-box;
		position: fixed;
		bottom: 0;
		left: 0;
		align-items: center;
		justify-content: space-between;
		z-index: 5;
		box-shadow: 0px 4px 10px 0px #353535;
	}
	
	
	.pay-button{
		height: 35px;
		width: 85px;
		background-image: linear-gradient(to right,#fc4141, #ff6e70);
		border-radius: 5px;
		color: #FFFFFF;
		line-height: 35px;
		text-align: center;
		font-weight: 500;
	}
	.opcity-bg{
		background-color: #1b1b1b;
		opacity: 0.5;
		height: 30px;
		border-radius: 20px;
		color: #FFFFFF;
		line-height: 30px;
		padding: 0 5px;
	}
	.opcity-bg2{
		background-color: #1b1b1b;
		opacity: 0.5;
		height: 30px;
		border-radius: 20px;
		color: #FFFFFF;
		line-height: 30px;
		padding: 0 5px;
	}
	.popup-button{
		background-color: #007AFF;
		height: 35px;
		line-height: 35px;
		border-radius: 4px;
		margin: 30px 20px 20px 20px;
		text-align: center;
		color: #FFFFFF;
	}
	
</style>
